@charset "utf-8";

// 定义select的基础构造
@mixin _select {
    @include flexbox;
    @include justify-content;
    position: relative;
    overflow: hidden;
    height: map-get($select, item-height) * map-get($select, item);
    background-color: white;
    > .list {
        position: relative;
        @include flex;
        text-align: center;
        > .item {
            height: map-get($select, item-height);
            line-height: map-get($select, item-height);
            padding: 0 .1rem;
            &.disabled {
                opacity: .4;
            }
        }
    }
    > .unit {
        position: relative;
        line-height: map-get($select, item-height) * 5;
        &:last-child {
            padding-right: .1rem;
        }
    }
    > .mask {
        position: absolute;
        z-index: 3;
        top: 0;
        right: 0;
        bottom: 0;
        left: 0;
        content: "\0020";
        pointer-events: none;
        background: -webkit-linear-gradient(top, white, rgba(255, 255, 255, .4) 40%, rgba(255, 255, 255, 0) 40%, rgba(255, 255, 255, 0) 60.5%, rgba(255, 255, 255, .4) 60.5%, white);
    }
    &::before {
        position: absolute;
        top: 50%;
        left: 0;
        content: "\0020";
        border: 1px solid map-get($select, border-color);
        border-width: 1px 0;
        @include responsive(retina1x) {
            width: 100%;
            height: map-get($select, item-height);
            @include transform(translatey(-50%));
        }
        @include responsive(retina2x) {
            width: 200%;
            height: map-get($select, item-height) * 2;
            @include transform(scale(0.5) translatey(-50%));
        }
        @include responsive(retina3x) {
            width: 300%;
            height: map-get($select, item-height) * 3;
            @include transform(scale(0.33333) translatey(-50%));
        }
        @include transform-origin(0 0);
    }
}

/**
 * @module widget
 * @method yo-select
 * @version 1.0.0
 * @description 构造yo-select的自定义使用方法（2.1.2版本优化了内部实现，精简了代码层级，匹配的kami版本为：）
 * @demo http://doyoe.github.io/Yo/demo/widget/yo-select.html
 * @param {String} $name 定义扩展名称 <1.0.0>
 * @param {Length} $item 显示的子项个数 <1.0.0>
 * @param {Length} $item-height 子项高度 <1.0.0>
 * @param {Color} $bordercolor 边框色 <1.0.0, 2.0.0>
 * @param {Color} $border-color 边框色 <2.0.0>
 */

@mixin yo-select(
    $name: default,
    $item: default,
    $item-height: default,
    $border-color: default) {
    // 区别是否新增实例还是修改本身
    $name: if($name == default, "", "-#{$name}");
    // 如果值为default，则取config的定义
    @if $item == default {
        $item: map-get($select, item);
    }
    @if $item-height == default {
        $item-height: map-get($select, item-height);
    }
    @if $border-color == default {
        $border-color: map-get($select, border-color);
    }
    .yo-select#{$name} {
        @if $item-height != map-get($select, item-height) or $item != map-get($select, item) {
            height: $item-height * $item;
        }
        > .list {
            > .item {
                @if $item-height != map-get($select, item-height) {
                    height: $item-height;
                    line-height: $item-height;
                }
            }
        }
        > .unit {
            position: relative;
            @if $item-height != map-get($select, item-height) or $item != map-get($select, item) {
                line-height: $item-height * $item;
            }
        }
        &::before {
            @if $item-height != map-get($select, item-height) {
                @include responsive(retina1x) {
                    height: $item-height;
                }
                @include responsive(retina2x) {
                    height: $item-height * 2;
                }
                @include responsive(retina3x) {
                    height: $item-height * 3;
                }
            }
            @if $border-color != map-get($select, border-color) {
                border-color: $border-color;
            }
        }

        // 增量扩展
        @content;
    }
}

// 调用本文件时载入select基础构造
.yo-select {
    @include _select;
}